Skip to content

OpenVPN Server unter Linux installieren

Als erstes laden wir uns das Skript openvpn-install.sh von https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh und machen es ausführbar.

root:~# curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh && chmod +x openvpn-install.sh

Installation

Während der Installation werden alle wichtige Fragen vom Script gestellt. Daher müssen wir keine Parameter angeben, sondern führen es einfach wie folgt aus. Zuerst setzen wir die IP-Adresse des OpenVPN Server, welche automatisch ermittelt wird.

root:~# ./openvpn-install.sh
Welcome to the OpenVPN installer!
The git repository is available at: https://github.com/angristan/openvpn-install

I need to ask you a few questions before starting the setup.
You can leave the default options and just press enter if you are ok with them.

I need to know the IPv4 address of the network interface you want OpenVPN listening to.
Unless your server is behind NAT, it should be your public IPv4 address.
IP address: 10.50.2.158

Wenn wir den OpenVPN Server im Heimischen Netz installieren, fragt das Skript nach der NAT IP-Adresse, die ebenfalls automatisch ermittelt wird. Hier wäre die MyFRITZ!-Adresse *****.myfritz.net hilfreich oder aber man hat einen DynDNS Hostnamen, der von der Fritz!Box aktualisiert wird.

It seems this server is behind NAT. What is its public IPv4 address or hostname?
We need it for the clients to connect to the server.
Public IPv4 address or hostname: *****.myfritz.net

Im nächsten Schritt wird gefragt, ob OpenVPN auch IPv6 verwenden soll.

Checking for IPv6 connectivity...

Your host does not appear to have IPv6 connectivity.

Do you want to enable IPv6 support (NAT)? [y/n]: n

Nun wird gefragt, welchen Port wir für OpenVPN verwenden wollen. Ich nehme den Standard Port UDP/1194.

What port do you want OpenVPN to listen to?
   1) Default: 1194
   2) Custom
   3) Random [49152-65535]
Port choice [1-3]: 1

Hier wird gefragt, ob wir OpenVPN über TCP oder UDP nutzen wollen.

What protocol do you want OpenVPN to use?
UDP is faster. Unless it is not available, you shouldn't use TCP.
   1) UDP
   2) TCP
Protocol [1-2]: 1

Als nächstes wir gefragt, wie die Hostauflösung genutzt werden soll. Ich verwende die aktuelle /etc/resolv.conf.

What DNS resolvers do you want to use with the VPN?
   1) Current system resolvers (from /etc/resolv.conf)
   2) Self-hosted DNS Resolver (Unbound)
   3) Cloudflare (Anycast: worldwide)
   4) Quad9 (Anycast: worldwide)
   5) Quad9 uncensored (Anycast: worldwide)
   6) FDN (France)
   7) DNS.WATCH (Germany)
   8) OpenDNS (Anycast: worldwide)
   9) Google (Anycast: worldwide)
   10) Yandex Basic (Russia)
   11) AdGuard DNS (Anycast: worldwide)
   12) NextDNS (Anycast: worldwide)
   13) Custom
DNS [1-12]: 1

Dann wird gefragt, ob wir eine Komprimierung verwenden wollen.

Do you want to use compression? It is not recommended since the VORACLE attack makes use of it.
Enable compression? [y/n]: n

In diesem Schritt könnten wir weitere Einstellungen vornehmen.

Do you want to customize encryption settings?
Unless you know what you're doing, you should stick with the default parameters provided by the script.
Note that whatever you choose, all the choices presented in the script are safe. (Unlike OpenVPN's defaults)
See https://github.com/angristan/openvpn-install#security-and-encryption to learn more.

Customize encryption settings? [y/n]: n

Somit wären wir mit dem Skript durch. Nun drücken wir eine beliebige Taste damit OpenVPN installiert und eingerichtet wird.

Okay, that was all I needed. We are ready to setup your OpenVPN server now.
You will be able to generate a client at the end of the installation.
Press any key to continue...

Client Zertifikat erstellen

Nach der Installation wird der erste Client eingerichtet. Dazu geben wir diesen einen Namen.

Tell me a name for the client.
The name must consist of alphanumeric character. It may also include an underscore or a dash.
Client name: my-example

Hier könnte man ein Passwort vergeben oder aber Passwortlos die Client Konfiguration erstellen.

Do you want to protect the configuration file with a password?
(e.g. encrypt the private key with a password)
   1) Add a passwordless client
   2) Use a password for the client
Select an option [1-2]: 2

In diesem Fall haben wir die Option 2 (mit Passwort) gewählt. Nun wird nach der PEM pass phrase gefragt, die wir zweimal eingeben, und fertig ist das erste Client Zertifikat.

⚠️ You will be asked for the client password below ⚠️

Note: using Easy-RSA configuration from: /etc/openvpn/easy-rsa/vars
Using SSL: openssl OpenSSL 1.1.1f  31 Mar 2020
Generating an EC private key
writing new private key to '/etc/openvpn/easy-rsa/pki/easy-rsa-28162.v4j2Bn/tmp.jQqew7'
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
-----
Using configuration from /etc/openvpn/easy-rsa/pki/easy-rsa-28162.v4j2Bn/tmp.g0LioW
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
commonName            :ASN.1 12:'my-example'
Certificate is to be certified until Feb  4 07:49:44 2025 GMT (825 days)

Write out database with 1 new entries
Data Base Updated

Client my-example added.

The configuration file has been written to /root/my-example.ovpn.
Download the .ovpn file and import it in your OpenVPN client.

Client Verwaltung

Führen wir das Skript erneut aus, fragt uns das Skript was wir gern machen wollen. Wir können weitere Clients hinzufügen, vorhandene Clients löschen oder aber OpenVPN wieder löschen.

root:~# ./openvpn-install.sh
Welcome to OpenVPN-install!
The git repository is available at: https://github.com/angristan/openvpn-install

It looks like OpenVPN is already installed.

What do you want to do?
   1) Add a new user
   2) Revoke existing user
   3) Remove OpenVPN
   4) Exit
Select an option [1-4]:

Dokumentation